# -*- coding: utf-8 -*-
# -------------------------------
# @软件：PyCharm
# @项目：news_spider
# @文件：feishu.py
# @时间：2024/11/8 21:28
# @作者：卷心菜
# @邮箱：doki7456@qq.com
# -------------------------------
import requests
import json

class FeishuTalk:
    # 机器人webhook
    chatGPT_url = "https://open.feishu.cn/open-apis/bot/v2/hook/a50f0a3f-ed99-4f5c-a076-a5b29314c5de"

    # 发送文本消息
    def sendTextmessage(self, content):
        url = self.chatGPT_url
        headers = {
            "Content-Type": "application/json; charset=utf-8",
        }
        payload_message = {
            "msg_type": "text",
            "content": {
                # @ 单个用户 <at user_id="ou_xxx">名字</at>
                "text": content + "<at user_id=\"bf888888\">test</at>"
                # @ 所有人 <at user_id="all">所有人</at>
                # "text": content + "<at user_id=\"all\">test</at>"
            }
        }
        response = requests.post(url=url, data=json.dumps(payload_message), headers=headers)
        return response.json

    # 执行发送文本消息

if __name__ == '__main__':
    content = "生活不止眼前的苟且，还有诗和远方!"
    FeishuTalk().sendTextmessage(content)
